/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
<template>
  <el-dialog
    title="取消订单"
    v-if="closeDialog"
    :visible.sync="closeDialog"
    append-to-body
  >
    <m-popover
      ref="popover"
      nameText="取消订单"
      @close="close"
      @ok="_ok"
    >
      <template slot="content">
        <div style="font-size:16px;padding:27px">
          <i
            class="el-icon-info"
            style="color:#F7564E;margin-right:10px"
          ></i>
          订单一旦被取消,该订单任务即将被暂停作废
        </div>
      </template>
    </m-popover>
  </el-dialog>
</template>
<script>
  import mPopover from '@/module/components/popup/popover'
  import { cancelProductOrder } from '@/conf/home/apis'
  export default {
    name: 'close-dialog',
    data () {
      return {
        closeDialog: false,
        item: null
      }
    },
    methods: {
      show (item) {
        this.item = item
        this.closeDialog = true
      },
      async _ok () {
        try {
          const res = await cancelProductOrder({ id: this.item.id })
          if (res && res.success) {
            this.$emit('refresh')
            this.close()
          } else {
            this.$message.warning(res.msg || '')
          }
        } catch (error) {
          console.log('error===>', error)
        }
      },
      close () {
        this.item = null
        this.closeDialog = false
      }
    },
    components: { mPopover }
  }
</script>
